import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sudoku/util/app_util.dart';
import 'package:sudoku/util/image_util.dart';

import 'MenuButton.dart';

class WinDialog extends StatelessWidget {
  final int time;

  WinDialog(this.time);

  @override
  Widget build(BuildContext context) {
    return Material(
      color: Colors.transparent,
      child: Center(
        child: Stack(
          children: [
            loadAssetImage("yellow_light"),
            loadAssetImage("halo"),
            Column(
              mainAxisSize: MainAxisSize.min,
              children: [
                const SizedBox(
                  height: 50,
                ),
                const Text(
                  "🎉",
                  style: TextStyle(fontSize: 120),
                ),
                Text(
                  "用时：${durationStr(time)}",
                  style: const TextStyle(
                      color: Colors.white,
                      fontFamily: "Han",
                      fontWeight: FontWeight.bold,
                      fontSize: 30),
                ),
                const SizedBox(
                  height: 30,
                ),
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceAround,
                  children: [
                    MenuButton(
                        onPressed: () {
                          Get.back(result: 1);
                        },
                        title: "返回首页"),
                    MenuButton(
                        onPressed: () {
                          Get.back(result: 2);
                        },
                        title: "再来一局"),
                  ],
                )
              ],
            )
          ],
        ),
      ),
    );
  }
}

Future showWinDialog(int time) {
  return showDialog(
      context: Get.context!,
      builder: (context) {
        return WinDialog(time);
      });
}
